import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import './plugins/element.js'
import TreeTable from 'vue-table-with-tree-grid'

// 导入样式表
import './assets/css/global.css'
import './assets/fonts/iconfont.css'

// 导入 NProgress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 导入 highlight.js
import hljs from 'highlight.js'
import 'highlight.js/styles/github.css'
Vue.use(hljs.vuePlugin);


Vue.config.productionTip = false

axios.defaults.baseURL = 'http://127.0.0.1:5800/api/private/v1/'
axios.interceptors.request.use(config => {
    NProgress.start();
    return config;
})
axios.interceptors.response.use(config => {
    NProgress.done();
    return config;
})
Vue.prototype.$http = axios


// 全局函数
Vue.prototype.$check_IpAddr = function (value) {
    var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
    if (!reg.test(value)) return `节点IP地址 "${value}" 格式错误`;
};

Vue.component('tree-table', TreeTable);
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')